import net.chrisrichardson.ec2deployer.cluster.ClusterManager
import net.chrisrichardson.ec2deployer.cluster.SimpleCluster

pluginHome = new File("./plugins").listFiles().find { it.name.startsWith('cloud-tools-')}
if(pluginHome == null) pluginHome = "."

includeTargets << new File("${pluginHome}/scripts/ExplodedWar.groovy")
includeTargets << new File("${pluginHome}/scripts/CloudToolsInit.groovy")

target('default': "Stop Cluster") {
    stop()
}

target(stop: "The implementation task") {
	depends( initCloudToolsService)
    cloudToolsService.withCluster{ClusterManager clusterManager, String clusterName, SimpleCluster cluster ->
        cluster.stop()
        clusterManager.removeCluster(clusterName)
    }
    event("StatusFinal", ["Stopped cluster"])

}
